package testcase;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.testng.annotations.Test;

import java.io.IOException;

public class HttpClientGetWithParam {
    @Test

    //Get请求带有头信息和cookie发送请求
    public void testName() throws IOException {
        HttpGet get=new HttpGet("http://localhost:12306/withCookiewithGet?name=chengliang&age=23");
//        //用来执行get方法的
        DefaultHttpClient client=new DefaultHttpClient();
        get.addHeader("cookie","login=true");
        HttpResponse response = client.execute(get);
        String result= EntityUtils.toString(response.getEntity());
        System.out.println(result);

    }

}
